

****************************************
************    TABLES  ****************
****************************************

capt drop _est_*


****   Short summary statistics (MAIN) 

foreach year in $yearlist{ 

preserve
collapse $Varlist_Fishery ,by(id_eez_tax $NonTreatmentGroup SampleMain iyear)
myttests $Varlist_Fishery if iyear==`year' & SampleMain==1  ///
, by($NonTreatmentGroup) unequal
eststo Varlist_Fishery_`year'
restore

preserve
collapse $Varlist_Specie ,by(id_eez_tax $NonTreatmentGroup SampleMain iyear)
myttests $Varlist_Specie if iyear==`year' & SampleMain==1  ///
, by($NonTreatmentGroup) unequal
eststo Varlist_Specie_`year'
restore

preserve
collapse $Varlist_EEZ  ,by(id_eez_tax $NonTreatmentGroup SampleMain iyear)
myttests $Varlist_EEZ if iyear==`year' & SampleMain==1  ///
, by($NonTreatmentGroup) unequal
eststo Varlist_EEZ_`year'
restore

preserve
collapse $Varlist_Country ,by(id_eez_tax $NonTreatmentGroup SampleMain iyear)
myttests $Varlist_Country if iyear==`year' & SampleMain==1  ///
, by($NonTreatmentGroup) unequal
eststo Varlist_Country_`year'
restore

}



// Make indent by changing the label name
// Remember to include --> preserve  restore
preserve
foreach v of varlist * {
	label variable `v' `"\hspace{0.2cm} `: variable label `v''"'
	}
foreach varlist in $Varlist_MAIN { 
esttab `varlist'_1975 `varlist'_2005 ///
using    "${tables}sum_`varlist'_1975_2005.tex"  , ///
unstack noobs  collabels(none) plain fragment ///
star(* 0.10 ** 0.05 *** 0.01) ///  
label  nonumber nomtitle onecell nogaps  ///
cells("mu_1(fmt(%12.2fc)) mu_2 d(star pvalue(d_p))" )  ///
replace
}
restore
*****************************



****************************************
************    FIGURES ****************
****************************************


/* Only PPR implementation */
preserve
collapse (mean) TreatMean=$Treatment  (sum) TreatSum=$Treatment ///
(count) NumStocks=id_eez_tax ///
, by($TreatmentGroup iyear) 
bysort $TreatmentGroup: egen MaxPPR=max(TreatSum)
bysort iyear: egen NumStocks2=sum(NumStocks)
gen Share=TreatSum/MaxPPR
gen ShareTot=TreatSum/NumStocks2*100
twoway ///
(line TreatSum iyear if $TreatmentGroup==1 , ///
lpattern(solid)  lwidth(medthick) lcolor("50 140 50*0.9"))   ///
(line ShareTot iyear if $TreatmentGroup==1 , ///
lpattern(shortdash)  lwidth(medthick) lcolor("50 140 50*0.9")  yaxis(2)) ///
 ,   ///
xscale(range(1950 2010))  ///
ytitle("Number of PPR implemented") ///
ytitle("% PPR of total number of stocks" , axis(2)) ///
legend(on order( 1 "Number of PPR implemented" ///
2 "% PPR of total number of stocks"  ) col(1))  ///
scheme(s2mono) graphregion(fcolor(white) )  ///
xsc(r(1950 2005)) xlabel(1950(10)2010) scale(1.3)   
graph export "${figures}PPR_Implemented_ver2.${fileformat}", as(${fileformat})  replace
restore



/*PPR impl per year*/
preserve
xtset  id_eez_tax iyear
gen DFppr_impl_trans=0
replace DFppr_impl_trans=1 if year_ppr_cc==iyear & $TreatmentGroup==1 
tab DFppr_impl_trans
collapse (sum) DFppr_impl_trans , by(iyear $TreatmentGroup)
gen DFppr_impl_trans2=DFppr_impl_trans
tab DFppr_impl_trans2
bysort $TreatmentGroup: egen MaxPPR=sum(DFppr_impl_trans2)
sum MaxPPR
gen Share=DFppr_impl_trans2/MaxPPR*100
twoway ///
(bar DFppr_impl_trans2 iyear  if $TreatmentGroup==1 ///
, lpattern(solid)   lcolor(black) color("50 140 50*0.7" ) ) ///
(bar Share iyear  if $TreatmentGroup==1 ///
, lpattern(solid)   lcolor(black) color("50 140 50*0.7" ) yaxis(2) ) ///
 ,   ///
ytitle("Number of PPR implemented ") ///
ytitle("% PPR implementation", axis(2)) ///
legend(on order( 1  "PPR implementation (annual)" )) ///
scheme(s2mono) graphregion(fcolor(white) lcolor(white)ifcolor(white) ///
ilcolor(white))  ///
ysc(r(0 0.20)) ///
xsc(r(1950 2005)) xlabel(1950(10)2010) scale(1.3)   
graph export "${figures}PPR_impl_annual.${fileformat}", as(${fileformat})  replace
restore



/*Collapsed*/
preserve
collapse collapsed , by($TreatmentGroup iyear)
replace collapsed=collapsed*100
twoway ///
(line collapsed iyear if $TreatmentGroup==0   , lpattern(dash) lwidth(medium) lcolor(black)) ///
(line collapsed iyear if $TreatmentGroup==1  , lpattern(solid) lwidth(medthick) lcolor(red) ) ///
 , /*xline(1975)*/  ytitle("Collapsed stocks (%)") ///
legend(on order( 1 "Non-PPR" 2 "PPR" )) ///
scheme(s2mono) graphregion(fcolor(white) lcolor(white)ifcolor(white) ///
ilcolor(white))  ///
ysc(r(0 0.3)) ylabel(0(10)30)  xsc(r(1950 2005)) xlabel(1950(10)2010) scale(1.3)  
graph export "${figures}collapsed_ppr_cc.${fileformat}", as(${fileformat}) /*preview(on)*/ replace
restore


/*IntoCollapse*/
preserve
collapse (mean) IntoCollapse , by($TreatmentGroup iyear)
gen IntoCollapse2=round(IntoCollapse,0.01)
replace IntoCollapse2=IntoCollapse2*100
xtset ppr_cc iyear
twoway ///
(bar IntoCollapse2 iyear if $TreatmentGroup==1  ,  lpattern(solid) lcolor(none) color(red)  lcolor(red)) ///
(bar IntoCollapse2 iyear if $TreatmentGroup==0  ,    lpattern(solid) lcolor(black) color(none) lwidth(medium) ) ///
 ,   ytitle("Transition into collapse (%)") ///
legend(on order( 1 "PPR" 2 "Non-PPR" )) ///
 graphregion(fcolor(white) lcolor(white)ifcolor(white) ///
ilcolor(white))  ///
ysc(r(0 0.08)) xsc(r(1950 2005)) xlabel(1950(10)2010) scale(1.3)  
graph export "${figures}IntoCollapse_ppr_cc_BAR.${fileformat}", as(${fileformat}) /*preview(on)*/ replace
restore


/* PPR implementation  + other*/
preserve
collapse (mean) $Treatment  (mean) ppr_other_num_time , by($TreatmentGroup iyear)
twoway ///
(line ppr_other_num_time iyear if $TreatmentGroup==0  , lpattern(dash) lwidth(medium) lcolor(gs6)) ///
(line ppr_other_num_time iyear if $TreatmentGroup==1  , lpattern(solid) lwidth(medthick) lcolor(black)) ///
(line $Treatment iyear if $TreatmentGroup==1 , lpattern(longdash)lwidth(medthick) lcolor(green) yaxis(2) ) ///
 ,   ytitle("PPR other environmental domains") ytitle("% PPR implemented", axis(2))   ///
legend(on order( 1 "IV (Non-PPR)" 2 "IV (PPR)"  3 "PPR fisheries" )) ///
scheme(s2mono) graphregion(fcolor(white) lcolor(white)ifcolor(white) ///
ilcolor(white))   ///
xsc(r(1950 2005)) xlabel(1950(10)2010) scale(1.3)  
graph export "${figures}PPR_Impl_Own_Other2.${fileformat}", as(${fileformat}) /*preview(on)*/ replace
restore

***********************************************************

capt drop _est_*
